﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;
using Model;
using System.Data;

namespace DataAccess
{
    public class DataMSAccess
    {
        OleDbConnection conn;
        OleDbCommand cmd;

        public DataMSAccess() {
            conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\C#\Thep\Database.accdb;Persist Security Info=False");
            cmd = conn.CreateCommand();
        }

        public void InsertLoaiThep(LoaiThep thep)
        {
            try
            {
                cmd.CommandText = "INSERT INTO LoaiThep(KieuSoHieu,ChieuCaoTietDien,ChieuDayBanBung,BeRongBanCanh,ChieuDayBanCanh,ChieuCaoDuongHan,DienTichTietDienCotThep) VALUES('" + thep.KieuSoHieu + "','" + thep.ChieuCaoTietDien + "','" + thep.ChieuDayBanBung + "','" + thep.BeRongBanCanh + "','"+thep.ChieuDayBanCanh+"','"+thep.ChieuCaoDuongHan+"','" + thep.DienTichTietDienCotThep + "')";
                cmd.CommandType = CommandType.Text;
                conn.Open();

                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null) conn.Close();
            }
        }

        



    }
}
